/**
 * Created with IntelliJ IDEA.
 * Description:start方法才会在操作系统内核里创建PCB
 * User: lenovo
 * Date: 2022-09-05
 * Time: 22:08
 */
class MyThread1 extends Thread{
    @Override
    public void run() {
        while (true){
            System.out.println("hello thread");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
public class Demo8 {
    public static void main(String[] args) throws InterruptedException {
        MyThread1 thread1 = new MyThread1();
        //thread1.run();//这里没有直接调用start方法,没有启动线程,会一直在run方法里面循环
        thread1.start();//在操作系统内核里创建PCB(线程),和原先的线程并发进行

        while (true){
            System.out.println("hello main");
            Thread.sleep(1000);
        }
    }

}
